package br.com.rglariguet.rgportal.dao.impl;

import org.hibernate.SessionFactory;
import org.hibernate.classic.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import br.com.rglariguet.rgportal.Empresa;
import br.com.rglariguet.rgportal.dao.EmpresaDAO;

@Repository
@Transactional
public class EmpresaDAOImpl implements EmpresaDAO {

	private final SessionFactory factory;
	
	@Autowired
	public EmpresaDAOImpl (SessionFactory factory){
		this.factory = factory;
	}
	
	private Session getSession() {
		return factory.getCurrentSession();
	}

	@Override
	public Empresa salvar(Empresa empresa) {
		getSession().save(empresa);
		return empresa;
	}

	
	
}
